package patterns.factory;

/**
 * Created by lenovo on 2016/11/22 0022.
 * 用于演示和测试工厂模式
 */
public class FactoryPatternDemo {
    public static void main(String[] args) {
        //获得工厂实例
        ShapeFactory factory = new ShapeFactory();
        //通过factory获取IShape接口类型的对象，来调用对应的方法，多态，不同的实现

        //圆形
        IShape shape1 = factory.getShape(Shapes.CIRCLE);
        shape1.draw();
        //矩形
        IShape shape2 = factory.getShape(Shapes.RECT);
        shape2.draw();
        //正方形
        IShape shape3 = factory.getShape(Shapes.SQUARE);
        shape3.draw();
    }
}
